package com.liuqi.knet.remoting;

import java.net.InetSocketAddress;

/**
 * @author liuqi
 * @date 2024/12/17 15:38
 **/
public interface Endpoint {

    /**
     * 获取通道IO处理器
     *
     * @return
     */
    ChannelHandler getChannelHandler();

    /**
     * 获取本地地址
     *
     * @return
     */
    InetSocketAddress getLocalAddress();

    /**
     * 发送请求
     *
     * @param message   {@link com.liuqi.knet.remoting.exchange.Request} or
     *                  {@link com.liuqi.knet.remoting.exchange.Event}
     * @throws RemotingException
     */
    void send(Object message) throws RemotingException;

    /**
     * 发送请求
     *
     * @param message   {@link com.liuqi.knet.remoting.exchange.Request} or
     *                  {@link com.liuqi.knet.remoting.exchange.Event}
     * @param sent      是否确认发送成功
     * @throws RemotingException
     */
    void send(Object message, boolean sent) throws RemotingException;

    /**
     * 关闭通道
     */
    void close();

    /**
     * 通道是否关闭
     *
     * @return
     */
    boolean isClosed();

}
